home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / kerberos / pc / krb_libk.lha / Lib / KRB / G_KRBRLM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-24  |  1.6 KB  |  62 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/get_krbrlm.c,v $
  3.  * $Author: rfrench $
  4.  *
  5.  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
  6.  * of Technology.
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>.
  10.  */
  11.  
  12. #ifndef lint
  13. static char *rcsid_get_krbrlm_c =
  14. "$Header: get_krbrlm.c,v 4.8 89/01/22 20:02:54 rfrench Exp $";
  15. #endif /* lint */
  16.  
  17. #include <mit_copy.h>
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include <krb.h>
  21.  
  22. /*
  23.  * krb_get_lrealm takes a pointer to a string, and a number, n.  It fills
  24.  * in the string, r, with the name of the nth realm specified on the
  25.  * first line of the kerberos config file (KRB_CONF, defined in "krb.h").
  26.  * It returns 0 (KSUCCESS) on success, and KFAILURE on failure.  If the
  27.  * config file does not exist, and if n=1, a successful return will occur
  28.  * with r = KRB_REALM (also defined in "krb.h").
  29.  *
  30.  * NOTE: for archaic & compatibility reasons, this routine will only return
  31.  * valid results when n = 1.
  32.  *
  33.  * For the format of the KRB_CONF file, see comments describing the routine
  34.  * krb_get_krbhst().
  35.  */
  36.  
  37. krb_get_lrealm(r,n)
  38.     char *r;
  39.     int n;
  40. {
  41.     FILE *cnffile, *fopen();
  42.  
  43.     if (n > 1)
  44.     return(KFAILURE);  /* Temporary restriction */
  45.  
  46.     if ((cnffile = fopen(KRB_CONF, "r")) == NULL) {
  47.     if (n == 1) {
  48.         (void) strcpy(r, KRB_REALM);
  49.         return(KSUCCESS);
  50.     }
  51.     else
  52.         return(KFAILURE);
  53.     }
  54.  
  55.     if (fscanf(cnffile,"%s",r) != 1) {
  56.         (void) fclose(cnffile);
  57.         return(KFAILURE);
  58.     }
  59.     (void) fclose(cnffile);
  60.     return(KSUCCESS);
  61. }
  62.